package com.xnyzc.lhy.common.penum;


import com.google.common.collect.Maps;
import com.xnyzc.lhy.common.entity.PEnum;

import java.util.Map;

/**
 * 用户登陆类型
 *
 * @Author:
 * @Date: 2019/1/4 11:34
 */
public enum EUserType implements PEnum<String> {

    manager("平台管理员", ERole.manager),
    fm("管理员", ERole.fm),
    d("司机", ERole.d),
    h("合力", ERole.h),
    c("乘客", ERole.c);

    private String desc;
    private Map<ERole, Byte> enabledRoles;

    EUserType(String desc, ERole... enabledRole) {
        this.desc = desc;

        Map<ERole, Byte> thisEnabledRoles = Maps.newHashMap();
        for (ERole eRole : enabledRole) {
            thisEnabledRoles.put(eRole, Byte.MAX_VALUE);
        }

        this.enabledRoles = thisEnabledRoles;
    }

    public Map<ERole, Byte> getEnabledRoles() {
        return enabledRoles;
    }

    @Override
    public String getValue() {
        return name();
    }

    @Override
    public String toString() {
        return name();
    }

    @Override
    public String toChString() {
        return desc;
    }
}
